package com.zhuang.designpattern.adapter;

import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

import com.alibaba.fastjson.JSON;
import com.zhuang.designpattern.adapter.impl.InsideOrderService;
import com.zhuang.designpattern.adapter.impl.POPOrderAdapterServiceImpl;

/**
 * description: Test
 * date: 2022/9/15 14:02
 * author: Zhuang
 * version: 1.0
 */
public class Test {
    public static void main(String[] args) throws ParseException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {
        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = s.parse("2022-09-15 23:20:16");

        create_account create_account = new create_account();
        create_account.setNumber("100001");
        create_account.setAddress("南京");
        create_account.setDesc("在学校");

        HashMap<String, String> link01 = new HashMap<>();
        link01.put("userId", "number");
        link01.put("bizId", "number");
        link01.put("desc", "desc");

        RebateInfo rebateInfo01 = MQAdapter.filter(create_account.toString(), link01);
        System.out.println("mq.create_account(适配前)" + create_account);
        System.out.println("mq.create_account(适配后)" + JSON.toJSONString(rebateInfo01));

        System.out.println("");

        OrderMq orderMq = new OrderMq();
        orderMq.setUid("100001");
        orderMq.setSku("10928092093111123");
        orderMq.setOrderId("100000890193847111");

        HashMap<String, String> link02 = new HashMap<>();
        link02.put("userId", "uid");
        link02.put("bizId", "orderId");
        RebateInfo rebateInfo02 = MQAdapter.filter(orderMq.toString(), link02);
        System.out.println("mq.orderMq(适配前)" + orderMq);
        System.out.println("mq.orderMq(适配后)" + JSON.toJSONString(rebateInfo02));

        System.out.println("");

        OrderAdapterService popOrderAdapterService = new POPOrderAdapterServiceImpl();
        System.out.println("判断首单，接口适配(POP)：" + popOrderAdapterService.isFirst("100001"));

        OrderAdapterService insideOrderService = new InsideOrderService();
        System.out.println("判断首单，接口适配(自营)：" + insideOrderService.isFirst("100001"));
    }
}
